﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Business.Partner;
using PJ.Data.SalePurchase.Sale;
using PJ.Business.Inventory;
using PJ.Framework.Common;

namespace PJ.Business.SalePurchase.Sale
{
    /// <summary>
    /// SaleInvoiceItemService class
    /// </summary>
    public class SaleInvoiceItemService : InvoiceItemService<ISaleInvoiceItem, ISaleInvoiceItemData, ISaleInvoiceItemProvider>, ISaleInvoiceItemService
    {
        #region Constructor

        /// <summary>
        /// Initialize
        /// </summary>
        /// <param name="dataService">Data provider</param>
        public SaleInvoiceItemService(ISaleInvoiceItemProvider dataService)
            : base(dataService)
        {
        }

        #endregion
        #region Interface implementation
        public ISaleInvoiceService SaleInvoiceService
        {
            get
            {
                if (_SaleInvoiceService == null)
                    _SaleInvoiceService = InjectionBroker.Resolve<ISaleInvoiceService>();
                return _SaleInvoiceService;
            }
        }
        public IInventoryItemSalesParamService InventoryItemSalesParamService
        {
            get
            {
                if (_InventoryItemSalesParamService == null)
                    _InventoryItemSalesParamService = InjectionBroker.Resolve<IInventoryItemSalesParamService>();
                return _InventoryItemSalesParamService;
            }
        }
        #endregion
        #region Interface override
        public override IInvoiceService InvoiceService
        {
            get { return SaleInvoiceService; }
        }
        public override IInventoryItemOrderParamService InventoryItemOrderParamService
        {
            get { return InventoryItemSalesParamService; }
        }
        #endregion

        #region Public
        public override ISaleInvoiceItem CreateNewItem()
        {
            return new SaleInvoiceItem(DataService.CreateNewItem());
        }
        #endregion
        #region Field
        
        private ISaleInvoiceService _SaleInvoiceService;
        private IInventoryItemSalesParamService _InventoryItemSalesParamService;
        
        #endregion


    }
}
